<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

$inline {{
./purecpp/html/header.html
}}

<body>
  <!-- 导航 -->
  $include {{
  ./purecpp/html/navigator.html
  }}
  <!-- 主体（一般只改变这里的内容） -->
  <div class="blog-body">
    <!-- 这个一般才是真正的主体内容 -->
    <div class="blog-container">
      <div class="blog-main">
		<fieldset class="layui-elem-field layui-field-title" style="margin-top: 70px;">
		  <legend>撰写新文章</legend>
		</fieldset>
		<form class="layui-form blog-editor" method="post" action="/add_post">
		
			  <div class="layui-form-item">
				<label class="layui-form-label" style="text-align: left;">文章标题</label>
				<div class="layui-input-block">
				  <input type="text" name="title" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
				</div>
			</div>
				<div class="layui-form-item">
						<label class="layui-form-label" style="text-align: left;">文章类型</label>
						<div class="layui-input-inline">
						  <select name="type" lay-verify="required">
							<option value=""></option>
							<option value="3">社区开源项目</option>
							<option value="4">代码精粹</option>
							<option value="5">modern c++资讯</option>
							<option value="7">社区活动</option>
							<option value="8">社区精华</option>
							<option value="25">技术探讨</option>
							<option value="47">C++11/14/17/20</option>
							<option value="58">元编程</option>
							<option value="49">社区故事</option>
							<option value="60">社区服务</option>
						  </select>
						</div>
				</div>
				<div class="layui-form-item" pane="">
					<button type="button" class="layui-btn" id="uploader">
						<i class="layui-icon"></i>上传图片
					</button>
					<div class="layui-input-block" style="display: inline-block;margin-left:11px;width:500px;">
						<input type="text" id="upload_file_url" name="upload_file_url" class="layui-input"></input>
					</div>
				</div>
				<div class="layui-form-item" pane="">
					<div id="post_content"># 初始数据放这里</div>
				</div>
				  <div class="clear"></div>
                  <div class="layui-form-item">
				  <button class="layui-btn" lay-submit="submit" lay-filter="submit">发布</button>
				  <button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
        </form>
		</div>
		</div>
		</div>
</body>
  <!--遮罩-->
  <div class="blog-mask animated layui-hide"></div>
<!-- layui.js -->
<script src="./purecpp/plug/laymd/layui/layui.js"></script>
<!-- 全局脚本 -->
<script src="./purecpp/js/global.js"></script>
<!-- 本页脚本 -->
<script src="/purecpp/plug/laymd/laymd/marked.min.js"></script>
<script>
    layui.config({base: './purecpp/plug/laymd/laymd/'}).use(['upload', 'layer', 'laymd','form'], function(){
        var layer = layui.layer,
            form = layui.form,
            laymd = layui.laymd;
			
			  var upload = layui.upload;
   
			  //执行实例
			  var uploadInst = upload.render({
				elem: '#uploader' //绑定元素
				,url: '/upload_file' //上传接口
				,accept: 'file'
				,done: function(res){
				  //上传完毕回调
				  layui.jquery('#upload_file_url').val(res.data.src);
				}
				,error: function(){
				  //请求异常回调
				}
			  });			

        //实例化编辑器,可以多个实例
        var md = laymd.init('post_content', {height:500});

        //内容改变事件
        md.on('change', function () {
            //这里借用marked.js解析效率比HyperDown快,用户可自行找解析器
            this.setPreview(marked(this.getText()));
        });

        //初始化数据预览
        md.do('change');

        form.render('select');

    });
</script>
</html>